package com.lixi.mapper.Impl;

import com.lixi.entity.Bat;
import com.lixi.mapper.BatMapper;
import com.lixi.utils.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author lixi
 * @create 2020-02-15:17:30
 */
public class BatMapperImpl implements BatMapper {
    public List<Bat> getBatList() {
        List<Bat> list=null;
        SqlSession sqlSession=null;
        try{
            sqlSession= MyBatisUtil.getSqlSession(true);
            list = sqlSession.getMapper(BatMapper.class).getBatList();
        }catch (Exception e) {
            e.printStackTrace();
        }finally{
            MyBatisUtil.ClosSqlSession(sqlSession);
        }
        return list;
    }

    public Integer addBat(Bat bat) {
        int res=0;
        SqlSession sqlSession=null;
        try{
            sqlSession=MyBatisUtil.getSqlSession(true);
            res = sqlSession.getMapper(BatMapper.class).addBat(bat);
        }catch (Exception e) {
            e.printStackTrace();
        }finally{
            MyBatisUtil.ClosSqlSession(sqlSession);
        }
        return res;
    }

    public Integer updBat(Bat bat) {
        int res=0;
        SqlSession sqlSession=null;
        try{
            sqlSession=MyBatisUtil.getSqlSession(true);
            res = sqlSession.getMapper(BatMapper.class).updBat(bat);
        }catch (Exception e) {
            e.printStackTrace();
        }finally{
            MyBatisUtil.ClosSqlSession(sqlSession);
        }
        return res;
    }
}
